<template>
    <div class="template-index-Lu">
        <commpVxeTable
            :key="reCommpVxeTable"
            :config="dataTableConfig"
            :columns="columnsVxe"
            :formItem="formItem"
            @checkboxChange="checkboxChange"
            ref="administrativeOffice"
            @searchEvent="searchEvent"
            @resetEvent="resetEvent"
            >
            <template v-slot:operation_fhtzt="{row}" data-desc="合同状态">
                <span v-if="row.fhtzt == '已支付'" style="color: #91cc75;">
                    {{ row.fhtzt }}
                </span>
                <span v-else style="color: #ee6666;">未支付</span>
            </template>
            <template v-slot:operation_fzfjd="{row}" data-desc="支付进度">
                <span>{{ Number(row.fzfjd * 100).toFixed(2) + '%' }}</span>
            </template>
            <template v-slot:operation_btn="{row}" data-desc="操作">
                <a-form layout="inline">
                    <a-form-item>
                        <a-button class="blue-btn" @click="handlerView(row)" icon="eye">查看</a-button>
                    </a-form-item>
                    <a-form-item v-if="row.fsffqlc !== '是'">
                        <a-button class="red-btn" @click="handlerDelete(row)" icon="delete">删除</a-button>
                    </a-form-item>
                </a-form>
            </template>
        </commpVxeTable>
        <printModal ref="printModalRef" :isOaModal="true"/>
        <nkModal v-show="false" ref="nkModalRef" ></nkModal>
    </div>
</template>
<script>
import {
    getMoreUserSignLinkList
} from '../contractPay/index/service/index'
import {
    htzfsqDelete
} from './service/index'
import  commpVxeTable   from '@/components/commp-vxe-table/commp-vxe-table.vue'
import assessCheckApi from "./service/api";
import printModal from '../contractPay/index/print'
export default {
    components: {
        commpVxeTable,
        printModal,
        nkModal: () => import('@/views/internalControl/yiBan/index'),
    },
    data() {
        return {
            reCommpVxeTable: '',
            dataTableConfig: {
                api: assessCheckApi.htzfsqList,
                rowId: 'id',
                urlType: true,
                paramet: {}
            },
            columnsVxe: [
                {
                    title: '合同编号',
                    field: 'fhtbh',
                },{
                    title: '合同名称',
                    field: 'fhtmc',
                },{
                    title: '合同金额',
                    field: 'fhtje',
                },{
                    title: '采购方式',
                    field: 'fcgfs',
                },{
                    title: '中标供应商名称',
                    field: 'fzbgysmc',
                },{
                    title: '支付进度',
                    field: 'fzfjd',
                    slots: {
                        default: 'operation_fzfjd',
                    },
                },{
                    title: '支付次数',
                    field: 'fzfcs',
                },{
                    title: '操作',
                    field: 'id',
                    width: 200,
                    slots: {
                    // 使用插槽模板渲染
                        default: 'operation_btn',
                    },
                },
            ],
            formItem: [
                {
                    label: '合同编号',
                    model: 'fhtbh',
                },{
                    label: '合同名称',
                    model: 'fhtmc',
                },{
                    label: '合同金额',
                    model: 'fhtje',
                },{
                    label: '采购方式',
                    model: 'fcgfs',
                },{
                    label: '中标供应商名称',
                    model: 'fzbgysmc',
                },{
                    label: '支付次数',
                    model: 'fzfcs',
                },
            ],
            idList: [],
            formData: {},
        }
    },
    methods: {
        // 勾选
        checkboxChange(val){
            //console.log('已选择',val)
            this.idList = []
            if(val.length){
                val.forEach(item => {
                    this.idList.push(item.id)
                });
            }
        },
        // 搜索
        searchEvent(){
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
        },
        // 重置
        resetEvent(){
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
        },
        handlerDelete(row){
            let that = this
            this.$confirm({
                title:'您确认要删除该申请吗？',
                onOk() {
                    htzfsqDelete({id:row.id}).then(res => {
                        if(res.success){
                            that.$message.success(res.message)
                            that.reCommpVxeTable = Date.now()
                        } else {
                            that.$message.warning(res.message)
                        }
                    })
                }
            })
        },
        handlerView(row){
            // let qmList = []
            // qmList = [
            //     {
            //         id: row.fjbrshrid,
            //         hjmc: '科室经办人审核',
            //         url: ''
            //     },{
            //         id: row.fksfzrshrid,
            //         hjmc: '科室负责人审核',
            //         url: ''
            //     },{
            //         id: row.fbgsfwshrid,
            //         hjmc: '办公室法务审核',
            //         url: ''
            //     },{
            //         id: row.fbgscwshrid,
            //         hjmc: '办公室财务审核',
            //         url: ''
            //     },{
            //         id: row.fbgsfzrshrid,
            //         hjmc: '办公室负责人审核',
            //         url: ''
            //     },{
            //         id: row.fzxldsprid,
            //         hjmc: '中心主任审批',
            //         url: ''
            //     },
            // ]
            // qmList.forEach(item => {
            //     getMoreUserSignLinkList({ids:item.id}).then(resa => {
            //         if(resa.result[0].signLink == ''){
            //             item.url = null
            //         } else {
            //             item.url = resa.result[0].signLink+'&aa='+Date.now()
            //         }
            //     })
            // })
            // this.$refs.printModalRef.getData(row,qmList)
            this.$refs.nkModalRef.reviseClick({fpid: row.id,flcmb:"NK_HTSPLC"})
        },
        cancel() {
            //console.log('Cancel');
        },
    },
}
</script>
